<template>
  <div class="deleteCommodity">
    <div class="box">
      <div class="tit">
        <h2>删除分类</h2>
      </div>
      <div class="val">
        <h3>分类id:</h3>
        <h3>{{ val }}</h3>
      </div>
      <div class="but">
        <el-button size="small">取消</el-button>
        <el-button type="primary" size="small" @click="ensure">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { deleteCommodity } from '@/api/deleteCommodity.ts'
import { useCounterStoreB } from '@/stores/temporary.ts'
const storeB = useCounterStoreB()
const val = ref(storeB.cat_id)

const ensure = async () => {
  try {
    await deleteCommodity(Number(val.value))
  } catch (error) {
    console.log(error)
  }
}

watch(
  () => storeB.cat_id,
  (i) => {
    val.value = i
  },
)
</script>

<style scoped lang="scss">
.box {
  padding: 20px;
  background: #fff;
  .tit {
    h2 {
      margin: 0;
    }
  }
  .val {
    display: flex;
  }
}
</style>
